:root {
    color-scheme: dark;
    font-family: "Space Grotesk", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    --clr-bg: #05060b;
    --clr-surface: rgba(12, 14, 25, 0.65);
    --clr-accent: #77f6ff;
    --clr-highlight: #ffd8a8;
    --clr-border: rgba(255, 255, 255, 0.08);
    --transition: 220ms ease;
}

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    color: #f3f5ff;
    background: radial-gradient(circle at 20% 20%, rgba(119, 246, 255, 0.25), transparent 45%),
                radial-gradient(circle at 80% 0%, rgba(255, 153, 102, 0.25), transparent 50%),
                radial-gradient(circle at 80% 70%, rgba(120, 117, 255, 0.35), transparent 55%),
                var(--clr-bg);
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 3rem 1.5rem;
    position: relative;
}

.noise-overlay {
    pointer-events: none;
    position: fixed;
    inset: 0;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160' viewBox='0 0 160 160'%3E%3Cfilter id='n' x='0' y='0'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.8' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='.15'/%3E%3C/svg%3E");
    mix-blend-mode: screen;
    opacity: 0.35;
    z-index: 0;
}

.app-shell {
    width: min(1100px, 100%);
    position: relative;
    z-index: 1;
    background: rgba(5, 7, 17, 0.65);
    border: 1px solid var(--clr-border);
    border-radius: 36px;
    padding: 2.5rem;
    backdrop-filter: blur(25px);
    box-shadow: 0 20px 80px rgba(1, 2, 6, 0.45);
}

.hero h1 {
    font-size: clamp(2rem, 4vw, 3.6rem);
    margin: 0.35rem 0 0.8rem;
}

.port-tag {
    display: inline-flex;
    padding: 0.3rem 0.8rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.12);
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

.lede {
    max-width: 620px;
    color: rgba(255, 255, 255, 0.8);
    font-size: 1.1rem;
}

.lede span {
    color: var(--clr-accent);
}

.tester {
    display: grid;
    grid-template-columns: minmax(240px, 320px) 1fr;
    gap: 2.5rem;
    margin-top: 2rem;
    align-items: center;
}

.halo {
    width: clamp(220px, 28vw, 320px);
    aspect-ratio: 1 / 1;
    background: radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.35), rgba(60, 66, 130, 0.55));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border: 1px solid rgba(255, 255, 255, 0.15);
    transition: transform var(--transition), filter var(--transition), box-shadow var(--transition), background var(--transition);
    box-shadow: 0 0 60px rgba(106, 163, 255, 0.4);
    cursor: pointer;
    overflow: hidden;
}

.halo::before {
    content: "";
    position: absolute;
    inset: -30%;
    background: radial-gradient(circle, rgba(119, 246, 255, 0.4), transparent 70%);
    opacity: 0.4;
    filter: blur(30px);
    transition: opacity var(--transition);
}

.halo-inner {
    text-align: center;
    z-index: 1;
}

.halo-status {
    margin: 0;
    font-size: 1.9rem;
    font-weight: 600;
}

.halo-hint {
    margin: 0.4rem 0 0;
    opacity: 0.7;
}

.halo.ready {
    filter: saturate(0.7);
    animation: idleGlow 3s ease-in-out infinite;
}

.halo.waiting {
    animation: waitingPulse 0.9s ease-in-out infinite;
}

.halo.active {
    background: radial-gradient(circle at 50% 40%, var(--clr-highlight), rgba(255, 71, 195, 0.4));
    box-shadow: 0 0 90px rgba(255, 150, 95, 0.7);
    transform: scale(1.02);
}

.halo.active::before {
    opacity: 0.8;
}

.halo.shake {
    animation: shake 0.4s;
}

@keyframes shake {
    0% { transform: translateX(0); }
    25% { transform: translateX(-6px); }
    50% { transform: translateX(6px); }
    75% { transform: translateX(-4px); }
    100% { transform: translateX(0); }
}

@keyframes idleGlow {
    0% { transform: scale(1); }
    50% { transform: scale(1.015); }
    100% { transform: scale(1); }
}

@keyframes waitingPulse {
    0% { box-shadow: 0 0 50px rgba(119, 246, 255, 0.45); }
    50% { box-shadow: 0 0 30px rgba(119, 246, 255, 0.2); }
    100% { box-shadow: 0 0 50px rgba(119, 246, 255, 0.45); }
}

.actions p {
    margin-top: 1rem;
    color: rgba(255, 255, 255, 0.72);
}

button.primary {
    border: none;
    background: linear-gradient(120deg, #62e4ff, #ff93b3, #ffd07f);
    color: #04131c;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 0.9rem 2.5rem;
    border-radius: 999px;
    cursor: pointer;
    transition: transform var(--transition), filter var(--transition), opacity var(--transition);
}

button.primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

button.primary:not(:disabled):hover {
    transform: translateY(-2px);
    filter: brightness(1.05);
}

.stats-grid {
    margin-top: 3rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1.25rem;
}

.stats-grid article {
    border: 1px solid var(--clr-border);
    border-radius: 20px;
    padding: 1.5rem;
    background: rgba(14, 16, 27, 0.75);
}

.stats-grid h2 {
    margin: 0.5rem 0 0;
    font-size: 2rem;
}

.label {
    margin: 0;
    text-transform: uppercase;
    color: rgba(255, 255, 255, 0.6);
    letter-spacing: 0.08em;
    font-size: 0.85rem;
}

.history {
    margin-top: 2.5rem;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2rem;
}

.history h3 {
    margin-bottom: 1rem;
}

.history ul {
    margin: 0;
    padding: 0;
    list-style: none;
    border: 1px solid var(--clr-border);
    border-radius: 18px;
    background: rgba(11, 12, 21, 0.8);
}

.history li {
    padding: 0.95rem 1.2rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.04);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.95rem;
}

.history li:last-child {
    border-bottom: none;
}

.history strong {
    font-size: 1.1rem;
}

@media (max-width: 900px) {
    .app-shell {
        padding: 1.8rem;
    }

    .tester {
        grid-template-columns: 1fr;
        text-align: center;
    }

    .halo {
        margin: 0 auto;
    }

    .actions p {
        text-align: left;
    }
}
